@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
24 lines (19 loc) • 582 B
text/typescript
import { FormInstance } from 'antd';
import { useLayoutEffect } from 'react';
import { useUserStore } from '@/store/user';
export const useSyncSystemAgent = (form: FormInstance, settings: any) => {
useLayoutEffect(() => {
// Set initial form values
form.setFieldsValue(settings);
// Sync form values with updated settings
const unsubscribe = useUserStore.subscribe(
(s) => s.settings.systemAgent,
(newSettings) => {
form.setFieldsValue(newSettings);
},
);
return () => {
unsubscribe();
};
}, [form, settings]);
};